package com.shop2cn.iapi.sellerpromotion.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;




import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.sellerpromotion.parameter.CreatePromotionBean;
import com.shop2cn.iapi.sellerpromotion.parameter.PromotionItem;
import com.shop2cn.iapi.sellerpromotion.parameter.editPromotionBean;
import com.shop2cn.iapi.sellerpromotion.service.CreatePromotionCall;
import com.shop2cn.iapi.sellerpromotion.service.editPromotionCall;
import com.ymatou.iapi.activitymanage.parameter.returnProductActivityStockBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.trading.operate.parameter.enums.PromotionTypeEnum;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.Shop2cnSellerPromotionCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.mongo.Shop2cnSellerPromotionInfoWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
/**
*编辑满减
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_editPromotion{
	private static editPromotionBean bean;
	private static editPromotionCall call;
	private static CreatePromotionBean createpromotionBean;
	private static CreatePromotionCall createpromotionCall;
	private static Integer mchId;
	private static Shop2cnSellerPromotionInfoWapper Shop2cnSellerPromotionInfoWapper;
	private static boolean autoend=true;
	@BeforeClass
	public static void setUp() throws Exception {
		Logger.createResultFile("编辑满减");
		Shop2cnSellerPromotionInfoWapper=new Shop2cnSellerPromotionInfoWapper();
		mchId=GodmchManageCallService.CreateSellerMch();
	}

	@Before
	public void caseUp() { 
		bean=new editPromotionBean();
		call=new editPromotionCall();
		createpromotionBean=new CreatePromotionBean();
		createpromotionCall=new CreatePromotionCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
		if(autoend) {
			try {
				Shop2cnSellerPromotionCallService.EndAllEnablePromotion(mchId);
			} catch (IOException e) {
			//			e.printStackTrace();
			}
		}
	}
	/**
	 * 创建满减
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private CreatePromotionBean CreatePromotion() throws ClientProtocolException, IOException
	{
		createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
		createpromotionCall.setData(createpromotionBean);
		createpromotionCall.callService();
		return createpromotionBean;
	}
	/**
	 * 编辑满减初始化
	 * @param createpromotionBean
	 * @return
	 */
	private editPromotionBean initEditPromotion(CreatePromotionBean createpromotionBean) {
		
		Integer promotionId=createpromotionCall.getJsonObject().getAsJsonObject().get("data").getAsJsonObject().get("promotionId").getAsInt();
		
		bean.setPromotionId(promotionId);
		bean.setSellerId(createpromotionBean.getSellerId());
		bean.setBegin(createpromotionBean.getBegin());
		bean.setEnd(createpromotionBean.getEnd());
		bean.setType(1);
		List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
		PromotionItem e=new PromotionItem();
		e.setLevel(1);
		e.setUseCondition(BigDecimal.valueOf(1));
		if(bean.getType()==1||bean.getType()==3) {
			//减10元
			e.setValue(BigDecimal.valueOf(10));
		}else {
			//9折
			e.setValue(BigDecimal.valueOf(9));
		}
		promotionItemList.add(e);
		bean.setPromotionItemList(promotionItemList);
		bean.setProductIdList(createpromotionBean.getProductIdList());
		return bean;
	}
	
	private void verifyDB(editPromotionBean createpromotionBean2) throws Exception {
		
		Map m = Shop2cnSellerPromotionInfoWapper.getPromotionById(bean.getPromotionId());
		//新增 20200729 是否显示在首页
		Logger.verifyEquals(bean.getShowHomePage(), (boolean)m.get("shp"), "验证shp");
		if (m != null && m.get("sid") != null) {
			Logger.verifyEquals(createpromotionBean2.getSellerId(), m.get("sid"), "验证SellerId");

			if (createpromotionBean2.getBegin().compareTo(YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS)) > 0) {
				Logger.verifyEquals(createpromotionBean2.getBegin().substring(0, 16),
						YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证bt");
			} else {
				Logger.verifyNotNull(YMTDateUtil.getFromDTSDate(m.get("bt").toString(), YMTDateUtil.YMDHMS), "验证bt");
			}

			Logger.verifyEquals(createpromotionBean2.getEnd().substring(0, 16),
					YMTDateUtil.getFromDTSDate(m.get("et").toString(), YMTDateUtil.YMDHMS).substring(0, 16), "验证et");
			
			Logger.verifyEquals(createpromotionBean2.getType(), m.get("type"), "验证type");
			
			// 1：全场商品 2：指定商品 
			if (createpromotionBean2.getProductIdList()==null||createpromotionBean2.getProductIdList().size()<=0) {
				Logger.verifyEquals(1, m.get("pjm"), "验证pjm");
			} else
				Logger.verifyEquals(2, m.get("pjm"), "验证pjm");
			}
			// 未操作
			Logger.verifyEquals(0, m.get("em"), "验证em");
			List<Map> lm = (List<Map>) m.get("vs");
			List<PromotionItem> pvl = createpromotionBean2.getPromotionItemList();
			Logger.verifyEquals(lm.size(), pvl.size(), "验证PromotionValueSize");
			int mytype = 0;
			if (PromotionTypeEnum.HalfIfCountEnough.getCode() == createpromotionBean2.getType() || PromotionTypeEnum.DiscountIfCountEnough.getCode() == createpromotionBean2.getType()
					|| PromotionTypeEnum.ReduceIfCountEnough.getCode() == createpromotionBean2.getType()) {
				// 满件
				Logger.debug("满件活动");
				mytype = 1;
			} else {
				// 满额
				Logger.debug("满额活动");
				mytype = 2;
			}
			// 多个验证
			for (PromotionItem promotionValue : pvl) {
				if (mytype == 1) {
					BigDecimal s = promotionValue.getUseCondition().setScale(2);
					BigDecimal v = promotionValue.getValue();
					for (Map tm : lm) {
						if (s.setScale(2).equals(BigDecimal.valueOf(Double.valueOf(tm.get("rv").toString())).setScale(2))) {
							verifyPromotionValue(createpromotionBean2.getType(), tm, promotionValue);
						}
						
					}
				} else if (mytype == 2) {
					BigDecimal s = promotionValue.getUseCondition();
					BigDecimal v = promotionValue.getValue();
					for (Map tm : lm) {
						if (s.setScale(2).equals(new BigDecimal(tm.get("rv").toString()).setScale(2))) {
							verifyPromotionValue(createpromotionBean2.getType(), tm, promotionValue);
						}
					}
				}
			}
			

			List<Map> psm = (List<Map>) m.get("ps");
			if (psm != null) {
				for (Map map : psm) {
					Logger.verifyNotNull(map.get("pidg"), "验证pidg");
					Logger.verifyNotNull(map.get("pidn"), "验证pidn");
					//这个字段目前没用
//					Logger.verifyNotEquals(0,map.get("pidn"), "验证pidn非0");
				}
				List<String> temppids = createpromotionBean2.getProductIdList();
				List<String> pids=new ArrayList<>();
				for (String string : temppids) {
					if(!pids.contains(string)){
						pids.add(string);
					}
				}
				Logger.verifyEquals(pids.size(), psm.size(), "验证PromotionValueSize");
				for (String pid : pids) {
					Logger.verifyIsContains(pid, psm.toString(), "验证包含pid");
				}
			}

	           //新增 20200810
			   Logger.verifyEquals(bean.getBannerUrl(), m.get("bn"), "验证bn");
			   Logger.verifyEquals(bean.getBgColor(), m.get("bgc"), "验证bgc");
			   Logger.verifyEquals(bean.getTitleColor(), m.get("tc"), "验证tc");
			   
		}
	private void verifyPromotionValue(int type, Map m, PromotionItem promotionValue) {
		if (type == 1) {
			Logger.verifyEquals(promotionValue.getUseCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(promotionValue.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
		// 折扣的时候/10
		else if (type == 2) {
			Logger.verifyEquals(promotionValue.getUseCondition().toString(), m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(promotionValue.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 3) {
			Logger.verifyEquals(promotionValue.getUseCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(promotionValue.getValue(), new BigDecimal(m.get("dv").toString()), "验证dv");
		} else if (type == 4) {
			Logger.verifyEquals(promotionValue.getUseCondition(), new BigDecimal(m.get("rv").toString()), "验证rv");
			Logger.verifyEquals(promotionValue.getValue().divide(BigDecimal.valueOf(10)), new BigDecimal(m.get("dv").toString()), "验证dv");

		} else if (type == 5) {
			Logger.verifyEquals("2", m.get("rv").toString(), "验证rv");
			Logger.verifyEquals(new BigDecimal(0.5), new BigDecimal(m.get("dv").toString()), "验证dv");

		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_001() {
		Logger.start(true,"编辑满减-优惠类型type=1满件折-满件减3-成功");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_001_1() {
		Logger.start(true,"编辑满减-同一促销类型修改促销值-type=1满件折,满件减3->type=1满件减,满件减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));//3->4
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_001_2() {
		Logger.start(true,"编辑满减-修改促销类型和促销值-type=2满件折,满件减3->type=1满件减,满件减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(1);//2->1
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_001_3() {
		Logger.start(true,"编辑满减-加一层级,-成功");
		try {
			//创建
            this.CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(1);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(99999));
		    e.setValue(BigDecimal.valueOf(5));
			promotionItemList.add(e);
			promotionItemList.add(createpromotionBean.getPromotionItemList().get(0));//增加一级
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_002() {
		Logger.start(true,"编辑满减-优惠类型type=2满件折-满额减4-成功");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_002_1() {
		Logger.start(true,"编辑满减-同一促销类型 修改促销值-type=2满件折,满件减3->type=2满件折,满件减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));//3->4
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_002_2() {
		Logger.start(true,"编辑满减-修改促销类型和促销值-type=2满件折,满件减3->type=1满件折,满件减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);//1->2
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_002_3() {
		Logger.start(true,"编辑满减-加一层级,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 2);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(1));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(44));
		    e.setValue(BigDecimal.valueOf(5));
			promotionItemList.add(e);
			promotionItemList.add(createpromotionBean.getPromotionItemList().get(0));//增加一级
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_003() {
		Logger.start(true,"编辑满减-优惠类型type=3满额折-满这减5-成功");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(3));
		    e.setValue(BigDecimal.valueOf(5));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_003_1() {
		Logger.start(true,"编辑满减-同一促销类型修改促销值-type=3满额折,满10减3->type=3满额折,满11减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(11));
		    e.setValue(BigDecimal.valueOf(4));//3->4
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_003_2() {
		Logger.start(true,"编辑满减-修改促销类型和促销值-type=3满额折,满10减3->type=2满件折,满件减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);//1->2
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(4));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_003_3() {
		Logger.start(true,"编辑满减-加一层级,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(20));
		    e.setValue(BigDecimal.valueOf(5));
			promotionItemList.add(e);
			promotionItemList.add(createpromotionBean.getPromotionItemList().get(0));//增加一级
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_004() {
		Logger.start(true,"编辑满减-优惠类型type=4满额折-满10减6折-成功");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(4);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(10));
		    e.setValue(BigDecimal.valueOf(6));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_004_1() {
		Logger.start(true,"编辑满减-同一促销类型修改促销值-type=4满额折,满10减3->type=4满额折,满11减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(4);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(11));
		    e.setValue(BigDecimal.valueOf(4));//3->4
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_004_2() {
		Logger.start(true,"编辑满减-修改促销类型和促销值-type=4满额折,满10减3->type=3满额减,满15减4,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);//1->2
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(15));
		    e.setValue(BigDecimal.valueOf(4));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_004_3() {
		Logger.start(true,"编辑满减-加一层级,-成功");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionBean.getPromotionItemList().get(0).setLevel(1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(10));
			createpromotionBean.getPromotionItemList().get(0).setValue(BigDecimal.valueOf(3));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(2);
			e.setUseCondition(BigDecimal.valueOf(20));
		    e.setValue(BigDecimal.valueOf(5));
			promotionItemList.add(e);
			promotionItemList.add(createpromotionBean.getPromotionItemList().get(0));//增加一级
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_005() {
		Logger.start(true,"输入错误type失败-失败013");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setType(6);//5：第二件半价
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_006() {
		Logger.start(true,"编辑满减-promotionId不存在-失败");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId()+111);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_007() {
		Logger.start(true,"编辑满减-sellerId不存在-失败");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setSellerId(bean.getSellerId()+111);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_008() {
		Logger.start(true,"编辑满减-begin不输入-失败");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setBegin(null);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_009() {
		Logger.start(true,"编辑满减-end不输入-失败");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setEnd(null);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_010() {
		Logger.start(true,"不输入promotionItemList失败-失败016");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionItemList(null);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_editPromotion_011() {
		//待确认 begin时间？
		Logger.start(true,"编辑满减-begin小于当前时间创建成功begin取当前时间-失败019待确定");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(-1,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_012() {
		Logger.start(true,"编辑满减-end小于begin失败-成功020");
		try {
			this.CreatePromotion();
			this.initEditPromotion(createpromotionBean);
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(2,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(1,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_013() {
		Logger.start(true,"编辑满减-2场同商品满减活动,时间不冲突成功021-成功");
		try {
			//创建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			//活动1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动1修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();	
			verifyDB(bean);	
			
			//活动2
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动2修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(5,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(6,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();			
			verifyDB(bean);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_014() {
		Logger.start(true,"编辑满减-创建2场同商品满减活动,时间冲突失败022");
		try {
			//创建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			//活动1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动1修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();	
			verifyDB(bean);	
			
			//活动2
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setProductIdList(productIdList);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动2修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss"));
			bean.setEnd(YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss"));
			call.setData(bean);
			call.callService();	
			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_015() {
		Logger.start(true,"编辑满减-2场同时间满减活动,商品不冲突成功023");
		try {//创建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId1 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList1=new ArrayList<String>();
			productIdList1.add(productId1);
			
		   String productId2 = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
		   List<String> productIdList2=new ArrayList<String>();
		   productIdList2.add(productId2);
			
			String begin=YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss");
			String end=YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss");
			//活动1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动1修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			bean.setProductIdList(productIdList1);
			call.setData(bean);
			call.callService();	
			verifyDB(bean);	
			
			//活动2
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动2修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			bean.setProductIdList(productIdList2);
			call.setData(bean);
			call.callService();			
			verifyDB(bean);			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_016() {
		Logger.start(true,"编辑满减-创建2场同时间满减活动,商品冲突失败024");
		try {
			//创建商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProductV2(mchId,"AutoTestMch",false);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> productIdList=new ArrayList<String>();
			productIdList.add(productId);
			
			String begin=YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss");
			String end=YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss");
			//活动1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动1修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			bean.setProductIdList(productIdList);
			call.setData(bean);
			call.callService();	
			verifyDB(bean);	
			
			//活动2
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动2修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			bean.setProductIdList(productIdList);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_017() {
		Logger.start(true,"编辑满减-2场同时间全场满减活动,失败025");
		try {

			String begin=YMTDateUtil.getBeforeOrNextDay(3,"yyyy-MM-dd HH:mm:ss");
			String end=YMTDateUtil.getBeforeOrNextDay(4,"yyyy-MM-dd HH:mm:ss");
			//活动1
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动1修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			call.setData(bean);
			call.callService();	
			verifyDB(bean);	
			
			//活动2
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 3);
			createpromotionBean.setName("AutoTest满减3_"+TestDataManager.getRandomIntNum(5));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//活动2修改时间
			this.initEditPromotion(createpromotionBean);
			bean.setPromotionId(bean.getPromotionId());
			bean.setBegin(begin);
			bean.setEnd(end);
			call.setData(bean);
			call.callService();			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_019() {
		Logger.start(true,"编辑满减-promotionItemList.useCondition为空失败027");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			//e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_020() {
		Logger.start(true,"编辑满减-promotionItemList.value为空失败028");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(1));
		   //e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_022() {
		Logger.start(true,"编辑满减-promotionItemList.useCondition负数失败030");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(-1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_023() {
		Logger.start(true,"编辑满减-promotionItemList.value负数失败031");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(-3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_024() {
		Logger.start(true,"编辑满减-满额折4promotionItemList.value大于等于9.9失败032");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(4);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(9.91));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_025() {
		Logger.start(true,"编辑满减-满件折2promotionItemList.value大于等于9.9失败033");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(9.91));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_026() {
		Logger.start(true,"编辑满减-创建满额减3promotionItemList.value大于等于promotionItemList.useCondition,失败034");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(9));
		    e.setValue(BigDecimal.valueOf(10));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_027() {
		Logger.start(true,"编辑满减-创建外币JPY满额减3promotionItemList.value有小数点失败036");
		try {
			Integer mchId2 = GodmchManageCallService.CreateCountrySellerMch("JPN");
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.setCurrency("JPY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);
			bean.setSellerId(mchId2);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
		    e.setUseCondition(BigDecimal.valueOf(10));
		    e.setValue(BigDecimal.valueOf(3.3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");
			Logger.verifyIsContains("不支持小数点", call.getString("message"), "验证message");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_editPromotion_028() {
		Logger.start(true,"编辑满减-满件减1多层级level2优惠小于level1(1:2件-10,2:3件-5)失败037");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(1);
			
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e1=new PromotionItem();
			e1.setLevel(1);
			e1.setUseCondition(BigDecimal.valueOf(2));
			e1.setValue(BigDecimal.valueOf(10));
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(5));
			
			promotionItemList.add(e1);
			promotionItemList.add(e2);
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
			//verifyDB(bean);		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_029() {
		Logger.start(true,"编辑满减-满件折2多层级level2优惠小于level1(1:2件8折,2:3件9折)失败038");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e1=new PromotionItem();
			e1.setLevel(1);
			e1.setUseCondition(BigDecimal.valueOf(2));
			e1.setValue(BigDecimal.valueOf(8));
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(9));
			
			promotionItemList.add(e1);
			promotionItemList.add(e2);
			bean.setPromotionItemList(promotionItemList);
			
			call.setData(bean);
			call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_030() {
		Logger.start(true,"编辑满减-多层级满减规则,满件折2-成功039");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(2);
			
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e1=new PromotionItem();
			e1.setLevel(1);
			e1.setUseCondition(BigDecimal.valueOf(2));
			e1.setValue(BigDecimal.valueOf(8));
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(3));
			e2.setValue(BigDecimal.valueOf(7));
			
			promotionItemList.add(e1);
			promotionItemList.add(e2);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_032() {
		Logger.start(true,"编辑满减-多层级满减规则-,满件减1-多层级依靠level排序041");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(3);
			e.setUseCondition(BigDecimal.valueOf(200));
			e.setValue(BigDecimal.valueOf(20));
			bean.getPromotionItemList().add(e);
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(150));
			e2.setValue(BigDecimal.valueOf(15));
			bean.getPromotionItemList().add(e2);
		
			promotionItemList.add(e);
			promotionItemList.add(e2);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_033() {
		Logger.start(true,"编辑满减-满件减1,UseCondition为小数时失败042");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(1);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1.1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_034() {
		Logger.start(true,"编辑满减-外币JPY满额减3promotionItemList.UseCondition有小数点失败043");
		try {
			//创建
			Integer mchId2 = GodmchManageCallService.CreateCountrySellerMch("JPN");
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId2, 3);
			createpromotionBean.setCurrency("JPY");
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			bean.setType(3);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(8.8));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");	
					
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_035_1() {
		Logger.start(true,"编辑满减-创建限时抢活动和全场满减不冲突-成功045");
		try {
			//创建限时抢活动
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createpromotionBean);
			call.setData(bean);
			call.callService();		
			
			verifyDB(bean);
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_035_2() {
		Logger.start(true,"编辑满减-限时抢活动和指定满减冲突失败-成功046");
		try {
			//创建限时抢活动
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);

			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createpromotionBean);
			bean.setProductIdList(Arrays.asList(pid));
			call.setData(bean);
			call.callService();		
			
			verifyDB(bean);
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_035() {
		Logger.start(true,"编辑满减-限时抢活动和指定满减商品不冲突时间冲突047");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(mchId,"AutoTest",false);
			String pid = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			String pid2=TestDataManager.getRandomUUID().toString();
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(mchId,pid);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(mchId, pid, catalogList);
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 4);
			//createpromotionBean.setProductIdList(Arrays.asList(pid2));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();			
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createpromotionBean);
			bean.setType(2);
			bean.setProductIdList(Arrays.asList(pid2));
			
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(8));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			
            bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();		
			
			verifyDB(bean);
			//限时折扣-终止活动
			AgentProductCallService.endactivity(mchId,activityId);	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_036() {
		Logger.start(true,"编辑满减-2场同商品满减活动,时间冲突失败-bug048");
		try {
			//活动满减1
			CreatePromotionBean createPromotionBean1=CreatePromotion();
			//活动满减2
			CreatePromotionBean createPromotionBean2=CreatePromotion();
			//活动满减3
			CreatePromotionBean createPromotionBean3=CreatePromotion();
			//活动满减4
			CreatePromotionBean createPromotionBean4=CreatePromotion();
			//活动满减5
			CreatePromotionBean createPromotionBean5=CreatePromotion();
			
			//创建p1 p2活动 再创建 p3 p4 活动 再创建p1 p2 活动 会通过的bug
            String p1 = TestDataManager.getRandomUUID().toString();
            String p2 = TestDataManager.getRandomUUID().toString();
            String p3 = TestDataManager.getRandomUUID().toString();
            String p4 = TestDataManager.getRandomUUID().toString();
            
         // createPromotionBean1=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
            this.initEditPromotion(createPromotionBean1);
			bean.setProductIdList(Arrays.asList(p1,p2));
			call.setData(createpromotionBean);
			call.callService();		
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createPromotionBean2);
			bean.setProductIdList(Arrays.asList(p3,p4));
			call.setData(createpromotionBean);
			call.callService();		
			Logger.verifyEquals("200", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createPromotionBean3);
			bean.setProductIdList(Arrays.asList(p1,p2));
			call.setData(createpromotionBean);
			call.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
			this.initEditPromotion(createPromotionBean4);
			bean.setProductIdList(Arrays.asList(p3,p4));
			call.setData(createpromotionBean);
			call.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");
			
		    this.initEditPromotion(createPromotionBean5);
			bean.setProductIdList(Arrays.asList(p1,p3));
			call.setData(createpromotionBean);
			call.callService();		
			Logger.verifyEquals("300", createpromotionCall.getString("code"), "验证返回");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_037() {
		Logger.start(true,"编辑满减-满件减使用条件不支持小数050");
		try {
			//创建
			createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);
			createpromotionBean.getPromotionItemList().get(0).setUseCondition(BigDecimal.valueOf(2));
			createpromotionCall.setData(createpromotionBean);
			createpromotionCall.callService();
			//修改
			initEditPromotion(createpromotionBean);
			
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1.5));
		    e.setValue(BigDecimal.valueOf(1));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("300", call.getString("code"), "验证返回");	 
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_039() {
		Logger.start(true,"编辑满减,多层级满减规则-,满件减1-使用条件2比使用条件1要小(level1:100,level2:50)-失败056");
		try {
			//之前是level2优惠要大于level1，现在改为level2使用条件要大于level1
           createpromotionBean=Shop2cnSellerPromotionCallService.initCreatePromotionBean(mchId, 1);//满件减
   		   createpromotionCall.setData(createpromotionBean);
		   createpromotionCall.callService();	
		   this.initEditPromotion(createpromotionBean);
		    //层级2必须比层级1的使用条件大
			PromotionItem e1=new PromotionItem();
			e1.setLevel(1);
			e1.setUseCondition(BigDecimal.valueOf(100));
			e1.setValue(BigDecimal.valueOf(20));
			
			PromotionItem e2=new PromotionItem();
			e2.setLevel(2);
			e2.setUseCondition(BigDecimal.valueOf(50));
			e2.setValue(BigDecimal.valueOf(30));
			bean.getPromotionItemList().add(e1);
			bean.getPromotionItemList().add(e2);
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("400", call.getString("code"), "验证返回");
			Logger.verifyEquals(true, call.getString("message").contains("层级2必须比层级1的使用条件大"), "验证返回message");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_040() {
		Logger.start(true,"编辑满减-是否显示在首页ShowHomePage=true");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			bean.setShowHomePage(true);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_041() {
		Logger.start(true,"编辑满减-是否显示在首页ShowHomePage=false");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			bean.setShowHomePage(false);
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_editPromotion_042() {
		Logger.start(true,"编辑满减-新增banner url、背景颜色、标题颜色 20200810-成功");
		try {
			//创建
			CreatePromotion();
			//修改
			initEditPromotion(createpromotionBean);
			List<PromotionItem> promotionItemList=new ArrayList<PromotionItem>();
			PromotionItem e=new PromotionItem();
			e.setLevel(1);
			e.setUseCondition(BigDecimal.valueOf(1));
		    e.setValue(BigDecimal.valueOf(3));
			promotionItemList.add(e);
			bean.setPromotionItemList(promotionItemList);
			//20200810
			bean.setBannerUrl("落地页banner_"+TestDataManager.getRandomIntNum(5));
			bean.setBgColor("背景颜色_"+TestDataManager.getRandomIntNum(5));
			bean.setTitleColor("标题颜色_"+TestDataManager.getRandomIntNum(5));
			
			call.setData(bean);
			call.callService();			
			
			verifyDB(bean);
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}